package design.mode.model.strategy.controller;

import design.mode.dispatcher.util.test.Test;
import design.mode.model.strategy.aware.MyContextUtil;
import design.mode.model.strategy.strategy.bean.MsgContent;
import design.mode.model.strategy.biz.AbstractBiz;
import design.mode.model.strategy.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;

@RestController
@RequestMapping
public class StrategyController {
    @Autowired
    private UserService userService;

    @PostMapping("/strategy")
    public ResponseEntity<String> strategy(@RequestBody MsgContent msgContent){
        //String s = MsgConfig.container.get(msgContent.getProcessType()).handleMsg(msgContent.getContent());
        AbstractBiz<Object> abstractBiz = MyContextUtil.getBeanName("SYS_MSG", "002");
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("id",100);
        paramMap.put("name","测试分发模式");
        Object result = abstractBiz.execute(paramMap);
        return ResponseEntity.ok(result.toString());
    }


    @PostMapping("/getResult")
    public ConcurrentLinkedQueue<Test> getResult () throws Exception {
        return userService.execute();
    }
}